package binaryTree;

/**
 * @author kunkun
 * @className LeetCode_104
 * @Description ...
 * @date 2025/3/22 20:15
 */
public class LeetCode_104 {

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public int maxDepth(TreeNode root) {
        return solution(root);
    }

    private int solution(TreeNode root) {
        if (root==null){
            return 0;
        }
        return Math.max(solution(root.left)+1,solution(root.right)+1);
    }

}
